﻿using System;
using System.Collections.Generic;
using System.Linq;
using SapaFinance.DTO;
using SapaFinance.Domain.Model;
using Xunit;

namespace SapaFinance.Tests
{
    public class RequestTest
    {
        public static IEnumerable<Request> Create()
        {
            var corp = CorporationTest.Create();
            var acc = new Account("345345", new Rub(), BankTest.Create(), CorporationTest.Create(), UserTest.Create());
            var paymentRequest = new Request(UserTest.Create())
            {
                PaymentPurpose = "Описание назначения платежа",
                Description = "Текст, оставленный автором",
                Unique = 567,
                PaymentPeriod = DateTime.Now
            };
            
            paymentRequest.SetPayer(corp);
            corp.AddAccount(acc);
            paymentRequest.SetPayee(corp);
            paymentRequest.SetPaymentType(PaymentTypeTest.Create());
            paymentRequest.SetPayeeAccount(acc);
            paymentRequest.SetPayment(2.00m);
            paymentRequest.SetTaxRate(18);
            paymentRequest.SetBudgetItem(BudgetItemTest.Create());
            return new List<Request>() { paymentRequest };
        }


        [Fact]
        public void CheckPaymentOrderCreate()
        {
            var paymentOrder = Create();
            paymentOrder.First().Accept(UserTest.Create());
            Assert.True(paymentOrder.First().IsAccepted);
            paymentOrder.First().Delete(UserTest.Create());
            Assert.True(paymentOrder.First().IsDeleted);
            Assert.NotNull(paymentOrder);
        }



        [Fact]
        public void test_create_request_dto()
        {
            var z = new RequestDTO();
            Assert.Null(z.SelectedPayee);
            Assert.Equal(Guid.Empty, z.SelectedPayer);


        }




    }
}